package com.hspedu.set_;

import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Set;

/**
 * @author DL5O
 * @version 1.0
 */
public class LinkedHashSetSource {
    public static void main(String[] args) {
        //分析一下LinkedHashSet的底层源码
        Set set = new LinkedHashSet();
        set.add(new String("AA"));
        set.add(456);
        set.add(456);
        set.add(new Customer("刘",1001));
        set.add(123);
        set.add("HSP");
        System.out.println(set);

        //解读
        //1.LinkedHashSet 加入元素的顺序和取出的顺序一致
        //2.LinkedHashMap 底层维护的是一个LinkedHashMap(是HashMap的子类)
        //3.
    }
}

class Customer{
    private String name;
    private int no;

    public Customer(String name, int no) {
        this.name = name;
        this.no = no;
    }

    public Customer(int no) {
        this.no = no;
    }

    @Override
    public String toString() {
        return "Customer{" +
                "name='" + name + '\'' +
                ", no=" + no +
                '}';
    }
}
